home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ABUSESRC.ZIP / AbuseSrc / imlib / acinclude.m4 next >
M4 Source File  |  1997-07-07  |  2KB  |  84 lines

  1. dnl AB_CHECK_FLAG(FLAG, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
  2. AC_DEFUN(AB_CHECK_FLAG,
  3. [
  4. AC_MSG_CHECKING([whether ifelse(AC_LANG, CPLUSPLUS, ${CXX}, ${CC}) supports the $1 flag])
  5. ab_flag_var=`echo $1 | sed 'y%./+-%__p_%'`
  6. AC_CACHE_VAL(ab_cv_flag_$ab_flag_var,
  7. [
  8. ifelse(AC_LANG, CPLUSPLUS, [
  9. ab_save_flags="$CXXFLAGS"
  10. CXXFLAGS="$CXXFLAGS $1"
  11. ], [
  12. ab_save_flags="$CFLAGS"
  13. CFLAGS="$CFLAGS $1"
  14. ])dnl
  15. AC_TRY_COMPILE(,[int a;],
  16. eval "ab_cv_flag_$ab_flag_var=yes", eval "ab_cv_flag_$ab_flag_var=no")
  17. ifelse(AC_LANG, CPLUSPLUS, CXXFLAGS="$ab_save_flags", CFLAGS="$ab_save_flags")
  18. ])
  19. if eval "test \"`echo '$ab_cv_flag_'$ab_flag_var`\" = yes"; then
  20.   AC_MSG_RESULT(yes)
  21.   ifelse([$2], , :, [$2])
  22. else
  23.   AC_MSG_RESULT(no)
  24. ifelse([$3], , , [$3
  25. ])dnl
  26. fi
  27. ])
  28.  
  29. dnl AB_ADD_FLAGS(FLAG...)
  30. AC_DEFUN(AB_ADD_FLAGS,
  31. [ab_flags=
  32. for ab_flag in $1; do
  33. AB_CHECK_FLAG([$ab_flag], [ab_flags="$ab_flags $ab_flag"])
  34. ifelse(AC_LANG, CPLUSPLUS, [
  35. ADDCXXFLAGS="$ab_flags"
  36. AC_SUBST(ADDCXXFLAGS)
  37. ], [
  38. ADDCFLAGS="$ab_flags"
  39. AC_SUBST(ADDCFLAGS)
  40. ])dnl
  41. done
  42. ])
  43.  
  44. AC_DEFUN(AB_C_BIGENDIAN,
  45. [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
  46. [ac_cv_c_bigendian=unknown
  47. # See if we have a good endian.h.
  48. AC_TRY_CPP([#include <endian.h>], [AC_TRY_COMPILE([#include <endian.h>], [
  49. #if !__BYTE_ORDER || !__BIG_ENDIAN
  50.   bogus endian macros
  51. #endif], [AC_TRY_COMPILE([#include <endian.h>], [
  52. #if __BYTE_ORDER != __BIG_ENDIAN
  53.  not big endian
  54. #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])])
  55. if test $ac_cv_c_bigendian = unknown; then
  56. # See if sys/param.h defines the BYTE_ORDER macro.
  57. AC_TRY_COMPILE([#include <sys/types.h>
  58. #include <sys/param.h>], [
  59. #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
  60.  bogus endian macros
  61. #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
  62. AC_TRY_COMPILE([#include <sys/types.h>
  63. #include <sys/param.h>], [
  64. #if BYTE_ORDER != BIG_ENDIAN
  65.  not big endian
  66. #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
  67. fi
  68. if test $ac_cv_c_bigendian = unknown; then
  69. AC_TRY_RUN([main () {
  70.   /* Are we little or big endian?  From Harbison&Steele.  */
  71.   union
  72.   {
  73.     long l;
  74.     char c[sizeof (long)];
  75.   } u;
  76.   u.l = 1;
  77.   exit (u.c[sizeof (long) - 1] == 1);
  78. }], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes)
  79. fi])
  80. if test $ac_cv_c_bigendian = yes; then
  81.   AC_DEFINE(WORDS_BIGENDIAN)
  82. fi
  83. ])
  84.